/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import dao.BilletDAO;
import dao.VenteDAO;
import entity.Billet;
 
import entity.Vente;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import org.jboss.weld.context.ejb.Ejb;

/**
 *
 * @author linos
 */
@ManagedBean(name = "transactionBean")
@SessionScoped
public class TransactionBean {

    @Ejb
    VenteDAO transactionDAO = new VenteDAO();
    List<Vente> transactions;
    Vente vente =new Vente();
    List<Billet> billets=new ArrayList<Billet>();
    @Ejb
    BilletDAO billetDAO=new BilletDAO();

    public TransactionBean() {
    }

      public String remplir()
    {   System.out.println("id="+vente.getId());
        billets=billetDAO.findByIdVente(vente.getId());
        System.out.println("size="+billets.size());
        return"transactionDetail.xhtml?faces-redirect=true";
    }

    public List<Billet> getBillets() {
        return billets;
    }

    public void setBillets(List<Billet> billets) {
        this.billets = billets;
    }
      
      
    public List<Vente> getTransactions() {
        int id;
        FacesContext context = FacesContext.getCurrentInstance();
        guichetBean bean = (guichetBean) context.getApplication().evaluateExpressionGet(context, "#{guichetBean}", guichetBean.class);
        id=bean.getUser().getId();
        return transactionDAO.findByGuichet(id);
    }

    public void setTransactions(List<Vente> transactions) {
        this.transactions = transactions;
    }

    public Vente getVente() {
        return vente;
    }

    public void setVente(Vente vente) {
        this.vente = vente;
    }
    
    
}
